



let test_obj = {
    closure_fn: function () {
        let that = this
        let timer = setTimeout(function () {
            console.log('Rambo!')
            that.closure_fn()
        }, 1000)
    }
}
test_obj.closure_fn()
test_obj = null

//虽然清除test_obj，但test闭包中定时器没释放，则一直执行
//解决方法如下：

let test_obj2 = {
    closure_fn: function () {
        let that = test_obj2
        let timer = setTimeout(function () {
            that ? that.closure_fn(): clearTimeout(timer)
            console.log('Rambo 2...!')

        }, 1000)
    }
}
test_obj2.closure_fn()
test_obj2 = null